package com.apes.hr.salary.rewardPunish.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.hr.salary.rewardPunish.model.TeamRewardPunish;
import com.apes.hr.salary.rewardPunish.model.TeamRewardPunishPre;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author linwz
 * @create 2019-02-27 09:47
 */
public interface TeamRewardPunishPreRepository extends CustomRepository<TeamRewardPunishPre, Long>{

    List<TeamRewardPunishPre> findByTeamRewardPunish(TeamRewardPunish teamRewardPunish);

    @Modifying
    @Query(value = "DELETE FROM HR_TEAM_REWARD_PUNISH_PRE T WHERE T.TEAM_REWARD_PUNISH_ID = :id AND T.STATE != 'approve'",nativeQuery = true)
    int deleteByTeamRewardPunishId(@Param("id")String id);


}
